<template>
  <div>
    <el-button type="primary" @click="willAdd">添加</el-button>
    <v-list :list="list" @init="init" @willEdit="willEdit"></v-list>
    <v-form ref="form" :user="user" @init="init"></v-form>
  </div>
</template>

<script>
import vForm from "./components/form.vue";
import vList from "./components/list.vue";
import { reqrolelist, reqroleinfo } from "../../request/api";
import { successAlert, errorAlert } from "../../utils/alert";
export default {
  
  data() {
    return {
      user: {
        isshow: false,
        isAdd: true,
      },
      list: [],
    };
  },
  components: {
    vForm,
    vList,
  },
  methods: {
    willEdit(id) {
      this.user.isshow = true;
      this.user.isAdd = false;
      this.$refs.form.getOne(id);
    },

    willAdd() {
      this.user.isshow = true;
      this.user.isAdd = true;
    },
    init() {
      reqrolelist().then((res) => {
        if (res.data.code === 200) {
          this.list = res.data.list;
          // successAlert(res.data.msg);
        }
      });
    },
  },
  mounted() {
    this.init();
  },
};
</script>

<style lang='less' scoped>
@import "../../less/index.less";
.el-button {
  margin-bottom: @margin;
}
</style>